﻿<?php
if(isset($_SESSION["user_id"])){
	if(!isset($_POST["valider"])){
?>
<form action="write_article.php" class= "main" method="post">
	<h1>Proposer un article</h1>
	<div class="input-group input-group-lg">
		<span class="input-group-addon">
			<label for="ttl">Titre</label>
		</span>
		<input type="text" name="title" id="ttl" class="form-control"/>
	</div>
	<textarea name="contentEditor" id="contentEditor" rows="10" cols="80">
	
	</textarea>
	<h3>Type de contenu</h3>
	<div class="input-group input-group-lg">
		<span class="input-group-addon">
			<label>News</label>
		</span>
		<input type="radio" name = "type" id = "type" class="form-control" checked value ="news" />
	</div>
	<div class="input-group input-group-lg">
		<span class="input-group-addon">
			<label>Test</label>
		</span>
		<input type="radio" name = "type" id ="type" class="form-control" value = "test"/>
	</div>
	<div class="input-group input-group-lg">
		<span class="input-group-addon">
			<label for = "comment_allowed">Autoriser les commentaires pour l'article</label>
		</span>
		<input type = "checkbox" name = "comment_allowed" id = "comment_allowed" class="form-control" value = "True" checked />
	</div>
	<div class="input-group input-group-lg">
		<span class="input-group-addon">
			<label>Image pour l'article:</label>
		</span>
		<input type="file" name="articleImg" id = "articleImg" class="form-control"/>
	</div>
	
	
	<input type="submit" id = "valider" name="valider" value="Envoyer" class="btn btn-primary btn-lg btn-block"/>
</form>
<?php 
	}else{
?>
<div class = "main">
	<p>Votre article a bien été envoyé, en attendant qu'un modérateur vous le valide.
	Vous pouvez le modifier grâce a l'onglet <a href = "../compte/compte.php?page=myArticles">mes articles</a> dans votre compte
	Merci de contribuer au site.</p>
</div>
<?php
	}
}else{ 
	header('Location: ../connexion.php');
}
?>

<script>
		// Replace the <textarea id="contentEditor"> with a CKEditor
		// instance, using default configuration.
		CKEDITOR.replace( 'contentEditor' );
</script>